package com.zhou.common.mybatis.template.shiro.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.zhou.common.lib.model.Response;
import com.zhou.common.mybatis.template.shiro.subscriber.TestSubscriber;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.event.EventBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ApiSupport(order = 2)
@Api(tags = {"eventBus测试类"})
@RestController
@RequestMapping("/bus")
public class TestEventBusController {

    @Autowired
    private EventBus eventBus;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "发送消息")
    @PostMapping("/send")
    public Response senMsg(String msg) {
        eventBus.publish(new TestSubscriber.FooEvent(msg));
        eventBus.publish(new TestSubscriber.BarEvent(msg));
        return Response.success();
    }


}
